home *** CD-ROM | disk | FTP | other *** search
- %%BeginFile: lw8_level1_colorimage-2.0
- /testsystemdict
- {
- where
- {
- systemdict eq
- {
- T
- }{
- F
- }ifelse
- }{
- F
- }ifelse
- }bd
- /rgbclut Z
- /bwclut Z
- /ncolors 1 def
- /colorimage where{pop T}{F}ifelse
- {
- /ncolors 0
- statusdict begin
- /processcolors where
- {
- pop
- pop
- processcolors
- }{
- /deviceinfo where
- {pop deviceinfo/Colors known
- {pop{deviceinfo/Colors get}}if
- }if
- }ifelse
- end
- store
- ncolors 0 ne
- {
- /colorimage testsystemdict
- /setcolortransfer testsystemdict
- /currentcolortransfer testsystemdict
- /currentcmykcolor testsystemdict
- and and and not
- {
- /ncolors 0 store
- }if
- }if
- }if
- ncolors 1 ne ncolors 3 ne ncolors 4 ne and and{/ncolors 0 store}if
- ncolors 1 ne dup startnoload
- /expandfactor Z
- /expandbw
- {
- expandfactor mul round cvi bwclut exch get 255 div
- }bd
- /:k
- {
- pop/bwclut xs
- bpc dup 8 eq
- {
- pop 255
- }{
- 4 eq
- {
- 15
- }{
- 3
- }ifelse
- }ifelse
- /expandfactor xs
- [
- /expandbw load/exec load dup
- currenttransfer exch
- ]cvx bind settransfer
- iw ih bpc[iw 0 0 ih 0 0]setupimageproc
- image
- }bd
- endnoload
- ncolors dup 3 eq exch 4 eq or
- not dup startnoload
- /Dclut Z
- /Cclut Z
- /Bclut Z
- /Aclut Z
- /ncompute Z
- /rclut Z
- /gclut Z
- /bclut Z
- /bit3x Z
- /bit1x Z
- /concatutil
- {
- /exec load
- 7 -1 roll/exec load
- }bd
- /defsubclut
- {
- 1 add getinterval store
- }bd
- /spconcattransfer
- {
- /Dclut xs
- /Cclut xs
- /Bclut xs
- /Aclut xs
- /ncompute exch load store
- currentcolortransfer
- [
- {
- Aclut ncompute
- }
- concatutil
- ]cvx
- [
- {
- Bclut ncompute
- }
- concatutil
- ]cvx
- [
- {
- Cclut ncompute
- }
- concatutil
- ]cvx
- [
- {
- Dclut ncompute
- }
- concatutil
- ]cvx
- setcolortransfer
- }bd
- /setuprgbcluts
- {
- /bit3x
- rgbclut length
- 3 sub
- store
- /bit1x bit3x 3 idiv store
- /rclut rgbclut store
- /gclut rclut 1 bit3x defsubclut
- /bclut rclut 2 bit3x defsubclut
- }bd
- endnoload
- ncolors 3 ne
- dup startnoload
- /str Z
- /len Z
- /smlen Z
- /rstr Z
- /gstr Z
- /bstr Z
- /kstr Z
- /cmykcluttorgbclut
- {
- /str xs
- /len str length store
- /smlen len 4 idiv store
- /rstr str store
- /gstr str 1 len 1 sub getinterval store
- /bstr str 2 len 2 sub getinterval store
- /kstr str 3 len 3 sub getinterval store
- 0 1 smlen 1 sub
- {
- dup 3 mul/str xs 4 mul/len xs
- kstr len get
- rstr dup len get
- 2 index add
- 255 exch sub dup 0 lt{pop 0}if
- str exch put
- gstr dup len get
- 2 index add
- 255 exch sub dup 0 lt{pop 0}if
- str exch put
- bstr dup len get
- 2 index add
- 255 exch sub dup 0 lt{pop 0}if
- str exch put
- pop
- }for
- rstr 0 smlen 3 mul getinterval
- }bd
- /3compute
- {
- exch bit3x
- mul
- round
- cvi
- get 255 div
- }bd
- /:k
- {
- /rgbclut xs
- pop
- $c devc eq
- {
- rgbclut cmykcluttorgbclut/rgbclut xs
- }if
- setuprgbcluts
- /3compute rclut gclut bclut dup
- spconcattransfer
- iw ih bpc[iw 0 0 ih 0 0]
- [
- setupimageproc/exec load
- /dup load dup
- ]cvx
- {}{}T 3 colorimage
- }bd
- endnoload
- ncolors 4 ne
- dup startnoload
- /cmykindex Z
- /bit4x Z
- /cmykclut Z
- /cclut Z
- /mclut Z
- /yclut Z
- /kclut Z
- /ftoint
- {
- 1 exch sub 255 mul round cvi
- }bd
- /stuffclut
- {
- cmykindex 3 -1 roll put
- }bd
- /4compute{exch bit4x mul round cvi get 255 div}bd
- /invalidcolortable? T def
- /computecmykclut
- {
- setuprgbcluts
- /bit4x
- rgbclut length
- 3 idiv
- 4 mul
- 4 sub
- store
- /cmykclut bit4x 4 add string store
- /cclut cmykclut store
- /mclut cclut 1 bit4x defsubclut
- /yclut cclut 2 bit4x defsubclut
- /kclut cclut 3 bit4x defsubclut
- /cmykindex 0 store
- 0 1 bit1x
- {
- dup/cmykindex exch
- bit1x exch sub
- 4 mul store
- 3 mul dup
- rclut exch get 255 div
- exch dup
- gclut exch get 255 div
- exch
- bclut exch get 255 div
- setrgbcolor currentcmykcolor
- ftoint
- kclut stuffclut
- ftoint
- yclut stuffclut
- ftoint
- mclut stuffclut
- ftoint
- cclut stuffclut
- }for
- }bd
- /innew Z
- /reverse4clut
- {
- dup length dup 4 sub/innew xdf
- string dup
- 3 -1 roll
- {
- 255 exch sub
- innew exch
- put dup
- innew 4 mod 3 eq
- {
- /innew innew 7 sub def
- }{
- /innew innew 1 add def
- }ifelse
- }forall
- pop
- }bd
- /:k
- {
- /rgbclut xs
- pop
- $c devc ne
- {
- computecmykclut
- }{
- /bit4x
- rgbclut length 4 sub
- store
- /cmykclut rgbclut reverse4clut store
- /cclut cmykclut store
- /mclut cclut 1 bit4x defsubclut
- /yclut cclut 2 bit4x defsubclut
- /kclut cclut 3 bit4x defsubclut
- }ifelse
- /4compute cclut mclut yclut kclut spconcattransfer
- iw ih bpc[iw 0 0 ih 0 0]
- [
- setupimageproc/exec load
- /dup load dup dup
- ]cvx
- {}{}{}
- T 4 colorimage
- }bd
- endnoload
- ncolors 0 ne
- dup startnoload
- /byte Z
- /$x Z
- /padfix Z
- /lookupandstore
- {
- 3 mul
- 3 getinterval
- putinterval exch
- 3 add exch 3 copy
- }bd
- /8lookup/lookupandstore load store
- /4lookup
- {
- /byte 1 index store
- -4 bitshift
- lookupandstore
- byte 15 and
- lookupandstore
- }bd
- /2lookup
- {
- /byte 1 index store
- -6 bitshift
- lookupandstore
- byte -4 bitshift
- 3 and
- lookupandstore
- byte -2 bitshift
- 3 and
- lookupandstore
- byte 3 and
- lookupandstore
- }bd
- /colorexpand
- {
- $x 0 rgbclut
- 3 copy
- 7 -1 roll
- /$l load
- forall
- pop pop pop pop pop
- 0 padfix getinterval
- }bd
- /createexpandstr
- {
- /$x exch $z length mul string store
- }bd
- /:k
- {
- /rgbclut xs
- /bwclut xs
- /$l
- bpc 8 eq
- {
- 3 createexpandstr
- /8lookup
- }{
- bpc 4 eq
- {
- 6 createexpandstr
- /4lookup
- }{
- 12 createexpandstr
- /2lookup
- }ifelse
- }ifelse
- load store
- /padfix 3 iw mul store
- iw ih 8[iw 0 0 ih 0 0]
- [setupimageproc/exec load/colorexpand load/exec load]cvx
- F 3 colorimage
- }bd
- endnoload
- /colorimage where
- {
- systemdict eq
- {
- systemdict/setcmykcolor known
- }{
- T
- }ifelse
- }{
- F
- }ifelse
- dup not startnoload
- /:l
- {
- iw ih 8[iw 0 0 ih 0 0]
- setupimageproc F 3
- $c devc eq
- {
- pop 4
- }if
- colorimage
- }bd
- dup not endnoload
- dup startnoload
- /str Z
- /len Z
- /smlen Z
- /rstr Z
- /gstr Z
- /bstr Z
- /rgbtogray
- {
- /str xs
- /len str length store
- /smlen len 3 idiv store
- /rstr str store
- /gstr str 1 len 1 sub getinterval store
- /bstr str 2 len 2 sub getinterval store
- str dup
- 0 1 smlen 1 sub
- {
- dup 3 mul
- rstr 1 index get .3 mul
- gstr 2 index get .59 mul add
- bstr 3 -1 roll get .11 mul add
- round cvi
- put dup
- }for
- pop 0 smlen getinterval
- }bd
- /kstr Z
- /cmyktogray
- {
- /str xs
- /len str length store
- /smlen len 4 idiv store
- /rstr str store
- /gstr str 1 len 1 sub getinterval store
- /bstr str 2 len 2 sub getinterval store
- /kstr str 3 len 3 sub getinterval store
- str dup
- 0 1 smlen 1 sub
- {
- dup 4 mul
- rstr 1 index get .3 mul
- gstr 2 index get .59 mul add
- bstr 2 index get .11 mul add
- kstr 3 -1 roll get add
- round cvi
- 255 exch sub dup 0 lt{pop 0}if
- put dup
- }for
- pop 0 smlen getinterval
- }bd
- /:l
- {
- iw ih 8[iw 0 0 ih 0 0]
- [setupimageproc/exec load
- $c devc eq
- {
- /cmyktogray
- }{
- /rgbtogray
- }ifelse
- load/exec load]cvx bind
- image
- }bd
- endnoload
- /:x
- {
- iw ih 8[iw 0 0 ih 0 0]
- setupimageproc
- image
- }bd
- %%EndFile
-